package com.cskaoyan.gateway.controller.shopping;

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.shopping.IProductService;
import com.mall.shopping.dto.AllProductRequest;
import com.mall.shopping.dto.AllProductResponse;
import com.mall.shopping.dto.PanelDto;
import com.mall.shopping.dto.RecommendResponse;
import com.mall.user.annotation.Anoymous;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Set;

@RestController
@RequestMapping("/shopping")
@Anoymous
public class ShoppingGoodsController {

    @Reference(timeout = 3000,check = false)
    IProductService iProductService;

    @GetMapping("/goods")
    public ResponseData getGoods(AllProductRequest allProductRequest){
        AllProductResponse allProduct = iProductService.getAllProduct(allProductRequest);
        return new ResponseUtil<AllProductResponse>().setData(allProduct);
    }

    @RequestMapping("/recommend")
    public ResponseData recommend(){
        RecommendResponse recommendGoods = iProductService.getRecommendGoods();
        return new ResponseUtil<Set<PanelDto>>().setData(recommendGoods.getPanelContentItemDtos());
    }
}
